//
//  BusinessAgreeController.m
//  ScalperMerchant
//
//  Created by 王云 on 2017/10/7.
//  Copyright © 2017年 WY. All rights reserved.
//

#import "BusinessAgreeController.h"
#import "BusinessSettledController.h"
@interface BusinessAgreeController ()<UIWebViewDelegate>

@property (nonatomic,assign)BOOL isAgree;


@end

@implementation BusinessAgreeController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"协议";
    
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[SCWebUrl stringByAppendingString:@"/faq_detail.html?id=3&simple_mode=1"]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
    
    [_webView loadRequest:request];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (IBAction)agreeClick:(id)sender {
    
    if (!_isAgree) {
        [SCTool showMessage:@"请同意入驻协议"];
        return;
    }
    BusinessSettledController *busineVC  = [[BusinessSettledController alloc] init];
    busineVC.token = _token;
    [self.navigationController pushViewController:busineVC animated:YES];

}

- (IBAction)cancel:(id)sender {

    __weak __typeof(&*self)weakSelf = self;
    [SCTool showAlerts:@"确定要取消入驻？" Ok:^(id alerts) {
        [weakSelf.navigationController popToRootViewControllerAnimated:YES];
    } Cancel:^(id alerts) {
        
    }];
    
}

- (IBAction)isAgree:(id)sender {
    
    UIButton *selectedButton = (UIButton *)sender;
    selectedButton.selected = !selectedButton.selected;
    _isAgree = !_isAgree;

}


- (void)webViewDidStartLoad:(UIWebView *)webView{
    [SCTool showLoading:@"正在加载"];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [SCTool hideHUD];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    
    [SCTool showError:@"加载失败"];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [SCTool hideHUD];
}



@end
